package com.sicnu.cheer.leaugebar.activity.profileset;

import android.content.Intent;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.sicnu.cheer.generalmodule.util.SharedPreferencesUtil;
import com.sicnu.cheer.leaugebar.activity.MainActivity;
import com.sicnu.cheer.generalmodule.activity.BaseActivity;
import com.sicnu.cheer.generalmodule.bean.MyUser;
import com.sicnu.cheer.profileset.R;
import com.sicnu.cheer.profileset.config.Constant;

import butterknife.InjectView;
import butterknife.OnClick;

/**
 * Created by cheer on 2017/2/10.
 * 个人资料导航页，用户第一次登录时对个人资料的设置之性别设置
 */
public class SexSetActivity extends BaseActivity implements View.OnClickListener {
    @InjectView(R.id.girl_iv)
    ImageView girlIV;
    @InjectView(R.id.boy_iv)
    ImageView boyIV;
    @InjectView(R.id.forward_step_tv)
    TextView forward;

    @Override
    protected void initView() {
        super.initView();
        MyUser myUser=MyUser.getCurrentUser(mThis,MyUser.class);
        if (myUser.getInit()!=null&&myUser.getInit()) {
            Intent intent=new Intent(mThis, MainActivity.class);
            startActivity(intent);
        }else {
            boyIV.setSelected(true);
            SharedPreferencesUtil.saveUserItem(mThis, Constant.SEX, "男");
            forward.setEnabled(false);
            findViewById(R.id.jump_to_main).setOnClickListener(this);
        }
    }

    @Override
    public int getContentViewId() {
        return R.layout.activity_sex_set;
    }

    @OnClick({R.id.girl_iv,R.id.boy_iv,R.id.next_step_tv})
    public void onClick(View v) {
        if (v.getId()==R.id.girl_iv){
            girlIV.setSelected(true);
            boyIV.setSelected(false);
        }else if (v.getId()==R.id.boy_iv){
            girlIV.setSelected(false);
            boyIV.setSelected(true);
        }else if (v.getId()==R.id.next_step_tv){
            //保存用户选择的性别
            SharedPreferencesUtil.saveUserItem(mThis, Constant.SEX,girlIV.isSelected()?"女":"男");
            //跳到生日选择界面
            Intent intent=new Intent(SexSetActivity.this,BirthdaySetActivity.class);
            startActivity(intent);
        }else if (v.getId()==R.id.jump_to_main){
            Intent intent=new Intent(mThis, MainActivity.class);
            startActivity(intent);
            finish();
        }
    }
}
